package edu.umn.csci5511.facedetection.haarfeatures;

public abstract class HaarMask {
	private final static int HAAR_FEATURE_LENGTH = 20;
	private static final int HAAR_FEATURE_WIDTH = 20;
	/**
	 * Each Haar Mask is a really a matrix which will be used So each subclass
	 * will define its own mask regions
	 */
	// http://www.tomgibara.com/computer-vision/HaarFilter.java
	int[][] haarFeatureMask;

	public HaarMask(int[][] maskArray) {
		if (maskArray != null
				&& correctDimensionsOfImage(maskArray, HAAR_FEATURE_LENGTH,
						HAAR_FEATURE_WIDTH))
			haarFeatureMask = maskArray;
	}

	private boolean correctDimensionsOfImage(int[][] maskArray, int length,
			int width) {

		boolean dimensionsAreCorrect = true;
		if (maskArray != null && maskArray.length != length) {
			dimensionsAreCorrect = false;
		} else {
			for (int[] oneDArray : maskArray) {
				if (oneDArray == null || oneDArray.length != width) {
					dimensionsAreCorrect = false;
					break;
				}
			}
		}

		return dimensionsAreCorrect;

	}

	private int[][] applyMaskToImageRectangle(int[][] image) {
		int[][] maskedImage = null;
		if(image != null && correctDimensionsOfImage(image, HAAR_FEATURE_LENGTH, HAAR_FEATURE_WIDTH)){
			maskedImage = internalApplyMaskOnImage(image);
		}
		return maskedImage;
	}

	//TODO: This image will probably come as a pixel map and so this method will change.
	private int[][] internalApplyMaskOnImage(int[][] image) {
		int[][] maskedImage = new int[HAAR_FEATURE_LENGTH][HAAR_FEATURE_WIDTH];
		for(int i = 0; i < HAAR_FEATURE_LENGTH; i++){
			
		}
		return maskedImage;
		
	}

}
